package com.rainbow.gray.framework.filter.discoveryclient;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;

// 用在DiscoveryClient 客户端获取discoveryClient.getInstances是才能使用到，本身框架的灰度流程暂不会使用
// 主要给客户端获取服务实例
public class ServerExecutor {
	
	@Autowired
    private List<ServerFilter> serverFilterList;

    public void onGetInstances(String serviceId, List<ServiceInstance> instances) {
        for (ServerFilter discoveryListener : serverFilterList) {
            discoveryListener.onGetInstances(serviceId, instances);
        }
    }

    public void onGetServices(List<String> services) {
        for (ServerFilter serverFilter : serverFilterList) {
        	serverFilter.onGetServices(services);
        }
    }

}
